package A01Function;

import java.util.ArrayList;
import java.util.Arrays;

public class FunctionTest3 {
    public static void main(String[] args) {
        //创建集合用来添加学生对象
        ArrayList<Student> list = new ArrayList<>();
        //添加学生对象
        list.add(new Student("张三",23));
        list.add(new Student("李四",24));
        list.add(new Student("王五",25));
        //获取名字和年龄并拼接
        String[] array = list.stream().map(FunctionTest3::p).toArray(String[]::new);
        System.out.println(Arrays.toString(array));

    }
    public static String p(Student student){
        return student.getName() + "-" + student.getAge();
    }
}
